from PySide6.QtWidgets import QDialog, QVBoxLayout, QTextBrowser, QPushButton, QTextEdit
from PySide6.QtCore import Qt

class AboutYeTuPlayer(QDialog):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setWindowTitle('关于野兔音乐播放器')
        self.setFixedSize(400, 260)
        
        layout = QVBoxLayout()
        
        self.text_browser = QTextBrowser()
        self.text_browser.setLineWrapMode(QTextEdit.NoWrap)
        self.load_about()
        
        close_btn = QPushButton('关闭')
        close_btn.clicked.connect(self.accept)
        
        layout.addWidget(self.text_browser)
        layout.addWidget(close_btn, alignment=Qt.AlignmentFlag.AlignRight)
        self.setLayout(layout)

    def load_about(self):
        try:
            with open('docs/about_yetuplayer.txt', 'r', encoding='utf-8') as f:
                self.text_browser.setText(f.read())
        except Exception as e:
            self.text_browser.setText(f'加载失败: {str(e)}')